<template>
	<view class="content">
		<view class="login-panel" v-if="!user.token">
			<view class="head-image">
				<image src="/static/user/head.png"></image>
			</view>
			<view class="user-info" @click="toLogin">
				登录/注册
			</view>
		</view>
		<view class="login-panel" v-if="user.token">
			<view class="head-image">
				<image :src="imageBaseUrl + user.photo"></image>
			</view>
			<view class="user-info">
				{{user.nickName}}
			</view>
		</view>
		<view class="function-list">
			<view class="function-item" @click="toUpdateUserPwd">
				修改密码
			</view>
			<view class="function-item" @click="loginOut">
				注销登录
			</view>
			<view class="function-item" @click="toFeedback">
				意见反馈
			</view>
			<view class="function-item" @click="toFeedbackList">
				反馈列表
			</view>
		</view>
	</view>
</template>

<script>
	import {image_base_url} from '@/api/config.js'
	import {mapMutations} from 'vuex'
	export default {
		data() {
			return {
				imageBaseUrl : image_base_url,
				user: {
					
				}
			};
		},
		created(){
			this.user = {
				...this.$store.state.user.userInfo, 
				token: this.$store.state.user.token
			}
		},
		methods:{
			...mapMutations(['clearInfo']),
			toLogin(){
				uni.navigateTo({
					url:'/pages/user/login/login'
				})
			},
			toUpdateUserPwd(){
				uni.navigateTo({
					url:'/pages/user/updateUserPwd/updateUserPwd'
				})
			},
			loginOut(){
				this.clearInfo()
				this.toLogin()
			},
			toFeedback(){
				uni.navigateTo({
					url:'/pages/user/feedback/feedback'
				})
			},
			toFeedbackList(){
				uni.navigateTo({
					url:'/pages/user/feedback/feedbackList'
				})
			}
		}
	}
</script>

<style lang="scss">
	.login-panel{
		height: 250rpx;
		width: 100%;
		background: linear-gradient(to bottom, rgba(18,150,219,0.8), rgba(18,150,219,0.2));
		display: flex;
		flex-direction: row;
		justify-content: left;
		align-items: center;
		color: #333;
		.head-image{
			width: 100rpx;
			height: 100rpx;
			margin-left: 50rpx;
			image{
				width: 100%;
				height: 100%;
				border-radius: 100%;
			}
		}
		.user-info{
			width: 300rpx;
			height: 150rpx;
			line-height: 150rpx;
			margin-left: 30rpx;
			letter-spacing: 8rpx;
			font-size: 40rpx;
		}
	}
	.function-list{
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		width: 100%;
		margin-top: 14rpx;
		.function-item{
			display: flex;
			justify-content: flex-start;
			align-items: center;
			width: 100%;
			height: 80rpx;
			background-color: white;
			padding-left: 50rpx;
			color: #3a3a3a;
			font-size: 30rpx;
			letter-spacing: 4rpx;
			border-bottom: solid 1rpx #f5f5f5;
		}
	}
</style>
